#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>

typedef struct
{
    int integer;
    char string[24];
} RECORD;

#define NRECORDS (100)

int main(int argc, char **argv)
{
    int f;
    RECORD *mapped;
    f = open("fwrite.dat", O_RDWR);
    mapped = (RECORD *)mmap(0, NRECORDS * sizeof(RECORD), PROT_WRITE | PROT_READ, MAP_SHARED, f, 0);
    printf("integer = %d \n string = %s \n", mapped[2].integer, mapped[3].string);

    munmap((void *)mapped,NRECORDS*sizeof(RECORD));

    return 0;
}